﻿<UserControl x:Class="BizControl.Presentation.CategoriesModule.Views.CategoriesView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             x:Name="CategoriesControl">

    <UserControl.Resources>
        <DataTemplate x:Key="CategoriesListBoxTemplate">
            <Border BorderThickness="0,0,0,1" BorderBrush="{StaticResource BorderLightBrush}">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="300" />
                        <ColumnDefinition Width="300" />
                        <ColumnDefinition Width="130" />
                    </Grid.ColumnDefinitions>
                    <TextBox Grid.Column="0" Text="{Binding Path=Name}" TextWrapping="Wrap"
                             VerticalAlignment="Center" MaxHeight="100" />
                    <TextBox Grid.Column="1" Text="{Binding Path=Description}" TextWrapping="Wrap"
                             VerticalAlignment="Center" MaxHeight="100" ScrollViewer.VerticalScrollBarVisibility="Auto"
                             ScrollViewer.CanContentScroll="True" />
                    <Button Grid.Column="2" HorizontalAlignment="Center" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch"
                            Width="25" Height="25" ToolTip="Редактировать категорию" Content="..."
                            Command="{Binding ElementName=CategoriesControl, Path=DataContext.EditCategoryCommand}"
                            CommandParameter="{Binding Path=Id}">
                    </Button>
                </Grid>
            </Border>
        </DataTemplate>
    </UserControl.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="30" />
            <RowDefinition Height="30" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <ToolBar>
            <Button HorizontalAlignment="Left" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch"
                    Width="25" Height="25" ToolTip="Обновить список"
                    Command="{Binding Path=RefreshListCommand}">
                <Button.Content>
                    <Image Source="{DynamicResource refreshImage}" />
                </Button.Content>
            </Button>
        </ToolBar>
        <!--<Grid Grid.Row="1" Background="{StaticResource BackgroundBrush}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="300" />
                <ColumnDefinition Width="300" />
            </Grid.ColumnDefinitions>
            <Border Grid.Column="0" BorderThickness="0,0,1,0" BorderBrush="{StaticResource SolidBorderBrush}" Margin="10,0,0,0">
                <TextBlock Text="Наименование категории" FontWeight="Bold" VerticalAlignment="Center" />
            </Border>
            <Border Grid.Column="1" BorderThickness="0,0,1,0" BorderBrush="{StaticResource SolidBorderBrush}">
                <TextBlock Text="Описание категории" FontWeight="Bold" VerticalAlignment="Center" />
            </Border>
        </Grid>-->
        <!-- Style="{StaticResource DefaultListBoxStyle}" ItemTemplate="{StaticResource CategoriesListBoxTemplate}" -->
        <DataGrid Grid.Row="2" AutoGenerateColumns="False" ItemsSource="{Binding Path=Model}">
            <DataGrid.Columns>
                <DataGridTextColumn Binding="{Binding Path=Name}" Header="Наименование категории" />
                <DataGridTextColumn Binding="{Binding Path=Description}" Header="Описание категории" />
            </DataGrid.Columns>
        </DataGrid>
    </Grid>
</UserControl>
